<template>
  <div>
    <a-modal v-model="visible" title="复制权限" @ok="handleOk" :centered="true" :destroyOnClose="true" width="260px">
      <j-search-select v-model="copyRoleId"   :dict="roleDict"  placeholder="请选择角色"   />
    </a-modal>
  </div>
</template>

<script>
import {postAction} from '@/api/manage'
import JSearchSelect from '@/views/scy/components/JSearchSelect.vue'

export default {
  name: 'CopyPermissionsList',
  components: { 
    JSearchSelect
  },
  props: {
    roleId: {
      type: String,
      default: '',
      require: false
    }
  },
  data() {
    return {
      visible: false,
      copyRoleId: '',
      roleDict: ''
    }
  },
  methods: {
    handleOk() {
      if (!this.copyRoleId) {
        this.$message.warning('请选择一个角色进行复制权限!')
        return
      }
      postAction('/api/erpmng/sys/role/saveCopyRolePermissions', { copyRoleId: this.copyRoleId, roleId: this.roleId })
        .then(res => {
          if (res.success) {
            this.$message.success(res.message)
            this.$emit('success-copy')
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {})
      this.visible = false
    }
  }
}
</script>
